//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<IDevice.h>
///	@path	~/src/graphics/
///	@date	2007/06/30
///	@desc	Device interface.

#pragma once

#include "xeres.h"

#include "object/IObject.h"

#include "database/IData.h"

#include "graphics/animation/frame.h"

namespace xeres {

	// forward declaration
	class IDeviceCallback;
	class IScreen;

	/*!
		\class	IDevice
		\brief	Interface of graphics device.

		\sa IDeviceCallback, IRenderer
	*/
	class IDevice : public IObject
	{
	public:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		IDevice( void );

		/// \dtor
		virtual ~IDevice( void );

		//@}

		DECL_IOBJECT_INTERFACE( IDevice , IObject );

	public:

		/// \name IDevice Interface
		//@{

		/*!
			\brief		Initialize device from a given window & configuration.
			\details
			\par Device configuration:
					The very data entry must contains these fields:
						- window
							- width			screen default width.
							- height		screen default height.
							- windowed		windowed tag.
						- device
							- antialias		1 ~ 16.
							- status		true or false.

			\return		Result of initialization.

			\param[in]	window		Handle of target window.
			\param[in]	config		Device configuration.
		*/
		virtual bool Initialize( void * window , RefWeak<IData> config ) = 0;

		/*!
			\brief		Finalize device & its context.
		*/
		virtual void Finalize( void ) = 0;

		/*!
			\brief		Tick call, give a chance to update device states.
		*/
		virtual void Tick( const Frame& frame ) = 0;

		/*!
			\brief		Change full screen state.
		*/
		virtual bool ToggleFullScreen( void * window ) = 0;

		/*!
			\brief		Determine if currently is full screen view.
		*/
		virtual bool IsFullScreen( void ) = 0;

		/*!
			\brief		Attach device callback.
			\param[in]	callback	Callback instance.
		*/
		virtual void AttachCallback( RefWeak<IDeviceCallback> callback ) = 0;

		/*!
			\brief		Call to enter device sizing.
		*/
		virtual void EnterSizing( void ) = 0;

		/*!
			\brief		Call to exit device sizing.
		*/
		virtual void ExitSizing( void ) = 0;

		/*!
			\brief		Call when window size maybe changed.
		*/
		virtual void OnSize( bool minized ) = 0;

		/*!
			\brief		Called before start to render scene.
		*/
		virtual bool IsEnableRender( void ) = 0;

		/*!
			\brief		Call to begin render.
			\details
					Return result must be checked, while false indicates the device is changing
					that device should not be render.
			\return		Enable render?
		*/
		virtual bool BeginRender( void ) = 0;

		/*!
			\brief		Call to end render & refresh representation.
		*/
		virtual void EndRender( void ) = 0;

		/*! 
			\brief		Call to query back buffer size.
		*/
		virtual Pair<int> GetBackBufferSize( void ) = 0;

		//@}
	};

} // namespace xeres
